/**
 * 题目链接：2025/10/26 考试 T1 字母项链
 * 完成时间：2025/10/26 14:30
 * 简要思路：
 */
#include <bits/stdc++.h>
#define range(i, b, e) for (auto i(b); i != (e); i++)
#define rep(i, b, e) for (auto i(b); i <= (e); i++)
#define req(i, b, e) for (auto i(b); i >= (e); i--)
using namespace std;
typedef long long LL;
typedef pair<int, int> Pii;

const int N = 5e4, M = 1e3;
int n, m;
char s[N+5], t[M+5];
int nxt[M+5], go[M+5][26];
int dp[2][M+5];

int getnext(int i, char ch) {
	int j = i;
	while (j && t[j+1] != ch) j = nxt[j];
	return j + (t[j+1] == ch);
}

int main() {
	freopen("neck.in", "r", stdin);
	freopen("neck.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cin >> s+1 >> t+1;
	n = strlen(s+1), m = strlen(t+1);

	for (int i = 2, j = 0; i <= m; i++) {
		while (j && t[j+1] != t[i]) j = nxt[j];
		j += t[j+1] == t[i];
		nxt[i] = j;
	}
	rep(i, 0, m-1) {
		rep(c, 0, 25) go[i][c] = go[nxt[i]][c];
		go[i][t[i+1] - 'a'] = i+1;
	}

	memset(dp[0], -0x3f, sizeof dp[0]);
	dp[0][0] = 0;
	rep(i, 0, n-1) {
		int p = i&1;
		memset(dp[p^1], -0x3f, sizeof dp[p^1]);
		rep(j, 0, m-1) {
			dp[p^1][j] = max(dp[p^1][j], dp[p][j]);
			if (go[j][s[i+1] - 'a'] < m) dp[p^1][go[j][s[i+1] - 'a']] = max(dp[p^1][go[j][s[i+1] - 'a']], dp[p][j] + 1);
		}
	}

	int ans = 0;
	rep(j, 0, m-1) ans = max(ans, dp[n&1][j]);
	cout << ans;
	return 0;
}
